#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import os

WORK_SPACE = os.path.dirname(os.path.abspath(__file__))

# 跨域配置
ALLOW_ORIGIN = ["*"]
ALLOW_CREDENTIALS = 'true'
ALLOW_METHODS = ["GET", "POST", "PATCH", "PUT", "DELETE", "OPTIONS"]

# 启动服务配置
SERVER_HOST = "0.0.0.0"
SERVER_PORT = 9090
SERVER_DEBUG = True

# 数据库
MYSQL_USERNAME = 'root'
MYSQL_PASSWORD = '123456'
MYSQL_HOSTNAME = 'localhost'
MYSQL_PORT = 3306
MYSQL_DATABASE = 'test'
MYSQL_CHARSET = 'utf8'


class Config:
    """ Flask 启动服务所需的 settings 内容 """
    SQLALCHEMY_ECHO = False  # 是否在终端打印sql
    SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{MYSQL_USERNAME}:{MYSQL_PASSWORD}@{MYSQL_HOSTNAME}:" \
                              f"{MYSQL_PORT}/{MYSQL_DATABASE}?charset={MYSQL_CHARSET}"

    API_TITLE = "Flask 模板 API 文档"
    API_VERSION = "1.0.0"
    OPENAPI_VERSION = "3.0.2"
    OPENAPI_JSON_PATH = "api-spec.json"
    OPENAPI_URL_PREFIX = "/v1"
    OPENAPI_REDOC_PATH = "/redoc"
    OPENAPI_REDOC_URL = "https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"
    API_SPEC_OPTIONS = {
        'servers': [{'url': 'http://127.0.0.1:10088/'}],
        'info': {
            'description': """请根据文档构建 HTTP 请求。"""
        },
    }

